package com.hax2max.core;

import com.hax2max.R;
import com.hax2max.service.FootprintUpdater;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class Programmet extends Activity {
    /** Called when the activity is first created. */
	Intent svc;
	Button meck;
	boolean trust;
	@Override
	
	
    public void onCreate(Bundle savedInstanceState) {
        trust=true;
		super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        svc = new Intent(this, FootprintUpdater.class);
        
      // FootprintUpdater.setApp(this);
        startService(svc);
        /*meck=
		(Button)findViewById(R.id.Button01);*/
        meck.setOnClickListener(new OnClickListener(){ 
        	public void onClick(View v)
        	{
        		mecka();
        	}

			
        });
        
	}
	private void mecka() {
		if (trust){
			serviceOff();
			trust=false;
			meck.setText("Start service");
	}
		else{
			trust=true;
			meck.setText("Stop service");
			startService(svc);
		}
	}
        
    
	@Override protected void onDestroy() {
		serviceOff();
		
	    Log.e("MECKET", Boolean.toString(stopService(svc)));
	    
	    super.onDestroy();

	}
	private void serviceOff() {
		stopService(svc);
	}
}